<?php
//创建Server对象，监听 127.0.0.1:9501端口

$server = new swoole_server('127.0.0.1', '9501', SWOOLE_PROCESS, SWOOLE_SOCK_TCP);

$server->on('connect', function ($server, $fd) {
    echo '链接成功';
});

$server->on('receive', function ($server, $fd, $from_id, $data) {
    $server->send($fd, '接受值' . $data);
});


$server->on('close', function ($server, $fd) {
    echo "Client: Close.\n";
});

//启动服务器
$server->start();